package net;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Queue;

public class ParaReader implements Runnable
{
	ObjectInputStream in;
	Queues<msg> CMDQueues;

	public ParaReader(ObjectInputStream in, Queues<msg> cmdq) {		
		this.in = in;
		CMDQueues = cmdq;
	}
	public void run()
	{
	//	while(true)
        {
			System.out.println("chay luong doc");
			msg p=new msg();
            try{
	             p = (msg) in.readObject();	            
	           
	            
	            Thread.sleep(100);
	           // if(p.getType() == MSGType.DISCONNECTED)
	            	//break; //Close reading	            
            }
            catch(Exception ex)
            {
                System.err.println("Reading errors");
            }
           try{ 
        	   CMDQueues.enqueue(p);
        	   
        	   }catch(Exception e)
        	   {
        		   System.out.println("bi loi CMDQueues.enqueue(p)");
        	   }
        }
	}
}